package com.example.web.websystem.controller;

import com.example.web.websystem.response.CommonReturnData;
import com.example.web.websystem.service.SysLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 各平台登录接口
 * <p>
 * Created by YangGang on 2019/03/31 17:42.
 */
@Api(tags = "登录")
@RestController()
@RequestMapping("/sys/login")
@Validated
public class SysLoginController {
    @Autowired
    private SysLoginService sysLoginService;


    @ApiOperation(value = "pc端-账号密码登陆")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "账号/邮箱/手机号", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "password", value = "密码", required = true)
    })
    @PostMapping("/web")
    public CommonReturnData login(String username, String password) {
        String token = sysLoginService.checkWebLogin(username, password);
        return CommonReturnData.success(token);
    }


}
